import React, { Component } from 'react'
import axios from 'axios'
import { RouteComponentProps } from 'react-router-dom'
interface IItem{
    cityId:number,
    name:string
}
export default class Film extends Component<RouteComponentProps,any> {
    state = {
        list:[]
    }
    componentDidMount(): void {
        axios({
            url:"https://m.maizuo.com/gateway?cityId=510100&ticketFlag=1&k=7884681",
            method:"get",
            headers:{'X-Client-Info': '{"a":"3000","ch":"1002","v":"5.2.1","e":"16580266551103961213894657"}',
            'X-Host': 'mall.film-ticket.cinema.list'}
        }).then(res=>{
            console.log('返回数据',res);
            this.setState({
                list:res.data.data.cinemas
            })
        })
    }
  render() {
    return (
      <div>Film
           <ul>
                    {
                        this.state.list.map( (item:IItem,index)=>
                        <li key={item.cityId * index} onClick={()=>{
                            console.log(item.cityId)
                            // this.props.history.push()
                            this.props.history.push(`/detail/${item.cityId}`)
                        }}>{item.name}</li>    
                        )
                    }
                </ul>
      </div>
    )
  }
}
